package com.yjhb.android.sbz.adapter;

import android.content.Context;
import android.content.Intent;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yjhb.android.sbz.R;
import com.yjhb.android.sbz.activity.ManageTaskActivity;
import com.yjhb.android.sbz.entity.TaskPublishState;
import com.jojo.android.zxlib.base.BaseRecyclerAdapter;

/**
 * 创建者 zx
 * 创建时间 2020/11/20 11:52
 */
public class TaskPublishStateAdapter extends BaseRecyclerAdapter<TaskPublishStateAdapter.TaskPublishStateHolder, TaskPublishState> {
    private final String TAG = "TaskPublishStateAdapter";

    public TaskPublishStateAdapter(Context context) {
        super(context);
    }

    @Override
    protected TaskPublishStateHolder getHolder(View v) {
        return new TaskPublishStateHolder(v);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.item_task_punlish_state;
    }

    @Override
    public void onBindViewHolder(@NonNull TaskPublishStateHolder taskPublishStateHolder, final int i) {
        Glide.with(context).load(data.get(i).getIcon()).into(taskPublishStateHolder.icon_iv);
        taskPublishStateHolder.state_tv.setText(data.get(i).getState());
        taskPublishStateHolder.num_tv.setText("" + data.get(i).getNum());
        taskPublishStateHolder.depict_tv.setText("" + data.get(i).getDepict());
        final int index = i;
        taskPublishStateHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, ManageTaskActivity.class);
                intent.putExtra("index", index);
                context.startActivity(intent);
            }
        });
    }


    class TaskPublishStateHolder extends RecyclerView.ViewHolder {
        ImageView icon_iv;
        TextView state_tv;
        TextView num_tv;
        TextView depict_tv;

        public TaskPublishStateHolder(@NonNull View itemView) {
            super(itemView);
            icon_iv = itemView.findViewById(R.id.icon_tv);
            state_tv = itemView.findViewById(R.id.state_tv);
            num_tv = itemView.findViewById(R.id.num_tv);
            depict_tv = itemView.findViewById(R.id.depict_tv);
        }
    }
}
